import { post, get } from '../../http/axios'


export default {
    //命名空间
    namespaced: true,
    //状态 - data  存储响应结果、变量
    state: {
        hospitalList: [],
        hospitalTotal: 0,
    },
    //突变   只能通过突变改变state中的变量值
    mutations: {
        setAllHospital(state, hospitalList) {
            state.hospitalList = hospitalList.list;
            state.hospitalTotal = hospitalList.total
        },

    },
    //动作   等价于methods,发送请求
    actions: {
        async saveHospital({ commit }, params) {
            let res = await post('/hospital/saveOrUpdate', params)
        },
        async findAllHospital({ commit }, params) {
            let res = await get('/hospital/pageQuery', params)
            commit('setAllHospital', res.data, )
        },
        async deleteHospital({ commit }, params) {
            let res = await get('/hospital/deleteById', params);
        },

    }
}